﻿using Common.Contract.Authentication.Record;
using Customer.Core.Data;
using Customer.Model.Interface;
using Customer.Model.Model;
using System.Collections.Generic;
using System.Linq;

namespace Customer.Provider
{
    public class BranchProvider : GenericProvider, IBranchProvider
    {
        public List<Branch> RetrieveAllBranches()
        {
            var data = repository.DbContext as CustomerEntities;

            var query = from x in data.Branchs
                        select x;
            return query.ToList();
        }
        public List<Branch> RetrieveBranchByDao(UserRecord dao)
        {
            var data = repository.DbContext as CustomerEntities;
            var query = from x in data.Branchs
                        select x;
            switch (dao.GroupIdentifier)
            {
                case "1":
                    break;
                case "0":
                    break;
                case "2":
                    query = query.Where(x => x.Region == dao.Zone);
                    break;
                default:
                    query = query.Where(x => x.BranchNameSme == dao.Branch);
                    break;
            }
            return query.ToList();
        }
    }
}
